<template>
  <i-frame :src="url" />
</template>
<script>
import iFrame from "@/components/iFrame/index";
export default {
  name: "WarmFlow",
  components: { iFrame },
  data() {
    return {
      url: ""
    };
  },
  mounted() {
    this.url = `${process.env.VUE_APP_IFRAME_URL}/flow-design/index/${this.$route.params.id}?disabled=${this.$route.query.disabled}&pageNum=${this.$route.query.pageNum}`;
    this.iframeLoaded();
  },
  methods: {
    iframeLoaded() {
      window.onmessage = (event) => {
        if (event.origin === process.env.VUE_APP_IFRAME_URL) {
          switch (event.data.method) {
            case "close":
              this.close();
              break;
          }
        }
      }
    },
    close() {
      const obj = { path: "/flow/definition", query: { t: Date.now(), pageNum: this.$route.query.pageNum } };
      this.$tab.closeOpenPage(obj);
    }
  }
};
</script>
